package com.hzp.lolnews.ui.discovery.presenter;

import com.hzp.lolnews.base.IBasePresenter;
import com.hzp.lolnews.bean.DiscoveryContent;
import com.hzp.lolnews.bean.DiscoveryNav;
import com.hzp.lolnews.ui.discovery.model.IDiscoveryImpl;
import com.hzp.lolnews.ui.discovery.model.OnLoadDiscoveryListener;
import com.hzp.lolnews.ui.discovery.view.IDiscoveryContent;

import java.util.List;

/**
 * Created by Administrator on 2016/10/21 0021.
 */
public class DiscoveryPresenter implements IBasePresenter {

    private IDiscoveryImpl discovery;
    private IDiscoveryContent discoveryView;

    public DiscoveryPresenter(IDiscoveryContent view){
        discovery = new IDiscoveryImpl();
        this.discoveryView = view;
    }

    public void loadData(){
        discovery.loadDiscovery(discoveryView.getPath(), new OnLoadDiscoveryListener() {
            @Override
            public void onSuccessDiscoveryNav(List<DiscoveryNav> list) {
                discoveryView.addDiscoveryNavi(list);
            }

            @Override
            public void onSuccessDiscoveryContent(List<DiscoveryContent> list) {
                //回调数据
                discoveryView.addDiscoveryContent(list);
            }



            @Override
            public void onFailure(String msg, Throwable e) {
                discoveryView.showLoadFailMsg(msg,e);
            }
        });
    }
}
